home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1993 September
/
clonecd
/
September 93.img
/
Archives
/
Fun, Tricks & Hacks
/
Ümlåût Õmêléttè
/
ü.a
< prev
next >
Wrap
Text File
|
1992-06-19
|
3KB
|
92 lines
CASE ON
INCLUDE 'Traps.a'
IMPORT Umlaut
InitEntry PROC EXPORT
IMPORT PatchStart
LEA InitEntry,A0 ; Get start address
_RecoverHandle ; Get the handle
_GetHandleSize ; And its size
LEA PatchStart,A0 ; Get the start of the patch
LEA InitEntry,A1 ; Get the start of the install code
SUBA.L A1,A0 ; Figure the length of the install code
SUB.L A0,D0 ; Figure length of the real code
MOVE.L D0,D1 ; Save a copy
_NewPtr ,sys ; Allocate room for the code
BNE.S ExitInstall ; Exit if error
MOVE.L A0,A1 ; Set up dest ptr
LEA PatchStart,A0 ; Set up src ptr
MOVE.L D1,D0 ; And length
_BlockMove ; Copy the code
MOVE.L #$82,D0 ; Load trap number
_GetTrapAddress ; Get that address
MOVE.L A0,$4(A1) ; Store in patch header
MOVE.L #$ED,D0 ; StdTxMeas trap id
_GetTrapAddress ; Get it
MOVE.L A0,$8(A1) ; Stuff it
MOVE.L #$600,D0 ; Allocate big ptr for buffer
MOVE.W D0,$10(A1) ; Store the size
_NewPtr ,sys ; Allocate the buffer
BNE.S ExitInstall ; Gack!
MOVE.L A0,$C(A1) ; Store it
MOVE.L A1,A0 ; Get patch address
MOVE.L #$82,D0 ; And trap number
_SetTrapAddress ; Set address
LEA $2(A1),A0 ; Get patch address (2nd)
MOVE.L #$ED,D0 ; And trap number
_SetTrapAddress ; Set address
ExitInstall:
RTS ; Done!
ENDP
; pascal void StdText(short count,const void *textAddr,Point numer,Point denom)
; pascal short StdTxMeas(short byteCount,const void *textAddr,Point *numer,
; Point *denom,FontInfo *info)
PatchStart PROC EXPORT
BRA.S TextPatch ; Jump past data record (2 bytes)
BRA.S MeasPatch ; (2 more bytes)
dataSpot:
DC.L 0 ; Old _StdText address (PatchStart+4,dataSpot+0)
DC.L 0 ; Old _StdTxMeas address (PatchStart+8,dataSpot+4)
DC.L 0 ; Ptr to intermediate buffer (PatchStart+C,dataSpot+8)
DC.W 0 ; How much room do we got? (PatchStart+10,dataSpot+C)
TextPatch:
MOVE.L $C(A7),A1 ; Get a pointer to text
MOVE.W $10(A7),D0 ; Get the length
JSR MungeText ; Munge the text
MOVE.L A1,$C(A7) ; Change buffer, if needed
MOVE.L dataSpot+0,A0 ; Get old address
JMP (A0) ; There we go!
MeasPatch:
MOVE.L $10(A7),A1 ; Get a pointer to text
MOVE.W $14(A7),D0 ; Get the length
JSR MungeText ; Munge the text
MOVE.L A1,$10(A7) ; Change buffer, if needed
MOVE.L dataSpot+4,A0 ; Get old address
JMP (A0) ; There we go!
MungeText:
MOVE.L (A5),A0 ; Get a pointer to QD globals
MOVE.L (A0),A0 ; Get a pointer to the current port
CMP.W #0,$44(A0) ; Is font system font?
BNE.S Fini ; If not, bail
CMP.W #0,$4A(A0) ; Is font system size?
BNE.S Fini ; Outa here
CMP.W $C+dataSpot,D0 ; Check amount of text against buffer size
BGE.S Fini ; If too small, die
EXT.L D0 ; Extend for BlockMove
MOVE.L D0,-(A7) ; For later call to Umlaut()
MOVE.L A1,A0 ; Get source address
MOVE.L $8+dataSpot,A1 ; Get dest
_BlockMove ; Move the text
MOVE.L A1,-(A7) ; Store address
JSR Umlaut ; Umlaut(char *buffer,int len);
ADD.L #$8,SP ; Pop arguments
MOVE.L $8+dataSpot,A1 ; Set up A1 to our buffer
Fini:
RTS
ENDP
END